# 1.创建sokcet对象
import socket
socket_client = socket.socket()
# 2.连接到服务端(ip端口为元组)
socket_client.connect(("localhost",8888))
# 3. 发送和接收消息
while True:
    send_client = input("客户端:")
    socket_client.send(send_client.encode("UTF-8"))         #发送消息
    server_data = socket_client.recv(1024).decode("UTF-8")  #接收消息
    print(f"服务端:{server_data}")

# 5.关闭连接
socket_client.close()
